from django.shortcuts import render

# Create your views here.
# -*- coding: utf-8 -*-


from ops.hades.models import Instance
from dvadmin.utils.serializers import CustomModelSerializer
from dvadmin.utils.viewset import CustomModelViewSet


class InstanceSerializer(CustomModelSerializer):
    """
    字典-序列化器
    """
    class Meta:
        model = Instance
        fields = '__all__'
        # exclude = ['passwd']
        read_only_fields = ["id"]


class InstanceViewSet(CustomModelViewSet):
    """
    字典管理接口
    list:查询
    create:新增
    update:修改
    retrieve:单例
    destroy:删除
    """
    exclude_field = ['passwd']
    queryset = Instance.objects.all()
    serializer_class = InstanceSerializer
    extra_filter_backends = []
    permission_classes = []
    search_fields = ["devices_name", "devices_num", "devices_type", "remark", "devices_localip", "devices_interip"]
